#ifndef TCPTHREAD_H
#define TCPTHREAD_H

#include <QObject>
#include <QThread>
class QTcpSocket;

class TcpThread : public QThread
{
    Q_OBJECT
public:
    explicit TcpThread(QObject *parent = nullptr);
    ~TcpThread();

    void setServer(const QString& ip, quint16 port);

    void send(const QByteArray& data);

signals:
    void sendData(QByteArray);
    void connected();
    void disconnected();
    void readyRead(QByteArray& data);

protected:
    void run();

private slots:
    void onReadyRead();
    void onConnected();
    void onDisconnected();
    void onSendData(QByteArray);
private:
    QString m_ip;
    quint16 m_port;
    QTcpSocket* m_socket;
};

#endif // TCPTHREAD_H
